<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>班级列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加','/clazz/toAddClazz')"><i
                            class="layui-icon"></i>添加班级
                    </button>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>班级id</th>
                            <th>班级名称</th>
                            <th>学院名称</th>
                            <th style="text-align: center">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <div>
                            <tr th:each="clazz,userStat:${list}">
                                <td style="text-align: center" th:text="${userStat.count}"></td>
                                <td style="text-align: center" th:text="${clazz.id}"></td>
                                <td style="text-align: center" th:text="${clazz.clazzName}"></td>
                                <td style="text-align: center" th:text="${clazz.collegeName}"></td>
                                <td class="td-manage" style="text-align: center">
                                    <a title="编辑"
                                       th:onclick="xadmin.open('编辑',[['/clazz/toEditClazz?id='+${clazz.id}]])"
                                       href="javascript:;">
                                        <i class="layui-icon">&#xe642;</i>
                                    </a>
                                    <a title="删除" th:onclick="member_del(this,[[${clazz.id}]])" href="javascript:;">
                                        <i class="layui-icon">&#xe640;</i>
                                    </a>
                                </td>
                            </tr>
                        </div>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {

            //发异步删除数据
            $.ajax({
                url: "/clazz/deleteClazz",
                type: "POST",
                data: {"id": id},
                dataType: 'json',
                success: function (result) {
                    if (result.code === 200) {
                        //弹出提示，并在1秒后进行跳转
                        layer.msg("删除成功", function () {
                            //关闭当前页面
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            //刷新父级页面
                            window.parent.location.reload();
                            return false;
                        });
                    } else {
                        layer.msg('失败,' + result.msg);
                    }
                },
            });

        });
    }
</script>
</html>
